From d43fb29c5abd53391816a4473affbb3afb53a2a0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?utf8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Sat, 2 Aug 2014 15:48:03 +0000 Subject: [PATCH] Suppress a warning from SetWindowLongPtr() https://bugzilla.gnome.org/show_bug.cgi?id=726224 --- gdk/win32/gdkwindow-win32.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index a8c7fc048c..d9bb81ee1c 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -1741,6 +1741,8 @@ gdk_win32_window_set_transient_for (GdkWindow *window, GdkWindow *parent) { HWND window_id, parent_id; + LONG_PTR old_ptr; + DWORD w32_error; GdkWindowImplWin32 *window_impl = GDK_WINDOW_IMPL_WIN32 (window->impl); GdkWindowImplWin32 *parent_impl = NULL; GSList *item; @@ -1799,14 +1801,28 @@ gdk_win32_window_set_transient_for (GdkWindow *window, g_object_ref (G_OBJECT (parent)); } + SetLastError (0); + old_ptr = GetWindowLongPtr (window_id, GWLP_HWNDPARENT); + w32_error = GetLastError (); + + /* Don't re-set GWLP_HWNDPARENT to the same value */ + if (old_ptr == parent_id && w32_error == NO_ERROR) + return; + + /* Don't return if it failed, try SetWindowLongPtr() anyway */ + if (old_ptr == 0 && w32_error != NO_ERROR) + WIN32_API_FAILED ("GetWindowLongPtr"); + /* This changes the *owner* of the window, despite the misleading * name. (Owner and parent are unrelated concepts.) At least that's * what people who seem to know what they talk about say on * USENET. Search on Google. */ SetLastError (0); - if (SetWindowLongPtr (window_id, GWLP_HWNDPARENT, (LONG_PTR) parent_id) == 0 && - GetLastError () != 0) + old_ptr = SetWindowLongPtr (window_id, GWLP_HWNDPARENT, (LONG_PTR) parent_id); + w32_error = GetLastError (); + + if (old_ptr == 0 && w32_error != NO_ERROR) WIN32_API_FAILED ("SetWindowLongPtr"); } -- 2.30.2